unit uclientes;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, Grids, DBGrids, DBTables, StdCtrls, Buttons;

type
  TFclientes = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    DBGrid1: TDBGrid;
    Button1: TButton;
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Fclientes: TFclientes;
  inclusao, alteracao, exclusao : boolean;


implementation

uses uclientesmanutencao, funcoes, udados;

{$R *.dfm}

procedure TFclientes.BitBtn5Click(Sender: TObject);
begin
close;
end;

procedure TFclientes.BitBtn1Click(Sender: TObject);
begin
inclusao := true;
application.createform(tfclientesmanutencao,fclientesmanutencao);
fclientesmanutencao.ShowModal;
inclusao := false;
fclientesmanutencao.Release;
end;



procedure TFclientes.BitBtn2Click(Sender: TObject);
begin
alteracao := true;
application.createform(tfclientesmanutencao,fclientesmanutencao);
fclientesmanutencao.ShowModal;
fclientesmanutencao.Release;
alteracao := false;
end;

procedure TFclientes.BitBtn3Click(Sender: TObject);
begin
exclusao := true;
application.createform(tfclientesmanutencao,fclientesmanutencao);
fclientesmanutencao.ShowModal;
fclientesmanutencao.Release;
exclusao := false;

end;

procedure TFclientes.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
     SelectNext(ActiveControl,true,true);
  if key=#27 then
     close;

end;

procedure TFclientes.Button1Click(Sender: TObject);
   var clickedok: boolean;
   var mtemp:string;

   begin
   ClickedOK := InputQuery('Procura','Expressao', mtemp);
   if not (clickedOK) or (mtemp = '') then
      exit;
   fdados.clientes.Next;
   fdados.clientes.DisableControls;
   while not fdados.clientes.eof do
    begin
         if pos(uppercase(mtemp),uppercase(fdados.clientesnome.value)) > 0 then
            break;
         fdados.clientes.next;
   end;
   fdados.clientes.enablecontrols;
   exit;
close;

end;

procedure TFclientes.FormActivate(Sender: TObject);
begin
fdados.clientes.first;
end;

end.
